<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class Users extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('users',array('comment' => '会员表'));
        $table
              ->addColumn('email', 'string', array('limit' => 255,'null' => true))
              ->addColumn('mobile', 'string', array('limit' => 20))
              ->addColumn('password', 'string', array('limit' => 255))
              ->addColumn('nickname', 'string', array('limit' => 30,'comment' => '昵称','null' => true))
              ->addColumn('real_name', 'string', array('limit' => 255,'comment' => '真实姓名','null' => true))
              ->addColumn('sex', 'integer', array('limit' => MysqlAdapter::INT_TINY,'null' => true))
              ->addColumn('wh_accpet', 'integer', array('comment' => '接收邮件','limit' => MysqlAdapter::INT_TINY,'default' => 0))
              ->addColumn('telephone', 'string', array('limit' => 255,'comment' => '固定电话','null' => true))
              ->addColumn('birthday', 'string', array('limit' => 255,'comment' => '生日','null' => true))
              ->addColumn('region', 'integer', array('comment' => '所在地区','null' => true))
              ->addColumn('address', 'string', array('limit' => 255,'comment' => '详细地址','null' => true))
              ->addColumn('head', 'string', array('limit' => 255,'comment' => '头像','null' => true))
              ->addColumn('authentication', 'integer', array('default' => 0, 'limit' => MysqlAdapter::INT_TINY,'comment' => '会员认证信息'))
              ->addColumn('type', 'integer', array('default' => 0, 'limit' => MysqlAdapter::INT_TINY,'comment' => '会员类型','null' => true))
              ->addColumn('camp_id', 'integer', array('comment' => '营地id','default' => 0,'limit' => MysqlAdapter::INT_TINY))
              ->addColumn('camp_name', 'string', array('limit' => 255,'comment' => '营地名称','null' => true))
              ->addColumn('park_num', 'string', array('limit' => 255,'comment' => '泊位编号','null' => true))
              ->addColumn('integral', 'integer', array('comment' => '旅行币','default' => 0)) 
              ->addColumn('reviewer', 'string', array('limit' => 255,'comment' => '审核人','null' => true))
              ->addColumn('status', 'integer', array('limit' => MysqlAdapter::INT_TINY,'comment' => '状态','default' => '0'))
              ->addColumn('login_session_id', 'string', array('limit' => 100,'null' => true))
              ->addColumn('phone', 'string', array('limit' => 255,'comment' => '手机号码','null' => true))
              ->addColumn('idnumber', 'string', array('comment' => '身份证号','null' => true))
              ->addColumn('open_id', 'string', array('comment' => '第三方openid', 'null' => true))
              ->addColumn('oauth_type', 'string', array('comment' => '', 'null' => true))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
			  ->addIndex('mobile',array('unique' => true))
              ->save();   
    }
    public function down()
    {
        $this->dropTable('users');
    }
}


